import requests
from lxml import etree

datas = []
page = 1
while True:
    url = f'http://quotes.toscrape.com/page/{page}'
    response = requests.get(url)
    tree = etree.HTML(response.content)
    items = tree.xpath('//div[@class="quote"]')
    for item in items:
        content = item.xpath('.//span[@class="text"]/text()')[0]
        author = item.xpath('.//small/text()')[0]
        tag = item.xpath('.//span[@class="tag"]/text()')[0]
        datas.append({
            'content': content[1:-1],
            'author': author,
            'tag': tag,
        })
    next_button = tree.xpath('//li[@class="next"]')
    if next_button:
        page += 1
    else:
        break


